/**
 * Created by Administrator on 2017/9/20.
 */
angular.module('module.saleStatistics', [
        'service.saleStatistics'
    ])

    .config(['$stateProvider', function ($stateProvider) {
        $stateProvider
            .state('saleStatistics', {
                url: '/saleStatistics',
                templateUrl: saleStatistics_view_url + 'saleStatistics.html',
                controller: 'SaleController',
                controllerAs: 'vm'
            })
            .state('callService', {
                url: '/callService',
                resolve: {
                    CallserviceList: ['$q', 'SaleService', '$localStorage', '$state', function ($q, SaleService, $localStorage, $state) {
                        if (!$localStorage[environmental + "shopid"]) {
                            $localStorage.$reset();
                            $state.go('login');
                        }
                        var shopid = $localStorage[environmental + "shopid"];
                        var time_start = new Date(new Date().getFullYear(), new Date().getMonth() - 1, new Date().getDate(), 0, 0, 0).getTime(); // 1����ǰ��ʱ���
                        var time_end = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 23, 59, 59).getTime(); // �����ʱ���
                        var deferred = $q.defer();
                        SaleService.callInfo(shopid, time_start, time_end).$promise.then(function (success) {
                            deferred.resolve(success);
                        }, function (error) {
                            deferred.resolve("undefined");
                        });
                        return deferred.promise;
                    }]
                },
                templateUrl: saleStatistics_view_url + 'callService.html',
                controller: 'callNumController',
                controllerAs: 'vm'
            })
            .state('bookService', {
                url: '/bookService',
                resolve: {
                    shopBookList: ['$q', 'SaleService', '$localStorage', function ($q, SaleService, $localStorage) {
                        var shopid = $localStorage[environmental + "shopid"];
                        var time_start = new Date(new Date().getFullYear(), new Date().getMonth() - 1, new Date().getDate(), 0, 0, 0).getTime();//1����ǰ��ʱ���
                        var time_end = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 23, 59, 59).getTime();//�����ʱ���
                        var deferred = $q.defer();
                        SaleService.getBookInfo(shopid, time_start, time_end).$promise.then(function (success) {
                            deferred.resolve(success);
                        }, function (error) {
                            deferred.resolve("undefined");
                        });
                        return deferred.promise;
                    }]
                },
                templateUrl: saleStatistics_view_url + 'bookService.html',
                controller: 'BookController',
                controllerAs: 'vm'
            })
            .state('uppervolume', {
                url: '/uppervolume',
                resolve: {
                    shopSaleList: ['$q', 'SaleService', '$localStorage', function ($q, SaleService, $localStorage) {
                        var shopid = $localStorage[environmental + "shopid"];
                        var time_start = new Date(new Date().getFullYear(), new Date().getMonth() - 1, new Date().getDate(), 0, 0, 0).getTime();//1����ǰ��ʱ���
                        var time_end = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 23, 59, 59).getTime();//�����ʱ���
                        var deferred = $q.defer();
                        SaleService.getUpInfo(shopid, time_start, time_end).$promise.then(function (success) {
                            deferred.resolve(success);
                        }, function (error) {
                            deferred.resolve("undefined");
                        });
                        return deferred.promise;
                    }]
                },
                templateUrl: saleStatistics_view_url + 'uppervolume.html',
                controller: 'upperVolumeController',
                controllerAs: 'vm'
            })

    }]);